// https://www.acwing.com/problem/content/800/

#include <iostream>
#include <vector>

using namespace std;

/*
输入
3 4 3
1 2 2 1
3 2 2 1
1 1 1 1
1 1 2 2 1
1 3 2 3 2
3 1 3 4 1

输出
2 3 4 1
4 3 4 1
2 2 2 2
*/
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int m, n, t;
    cin>>m>>n>>t;
    vector<vector<int>> matrix(m+2, vector<int>(n+2));
    vector<vector<int>> diff(m+2, vector<int>(n+2));
    for (int i=1; i <= m; i++) {
        for (int j=1; j<=n; j++) {
            cin>>matrix[i][j];
            diff[i][j] = matrix[i][j];
        }
    }

    auto update = [&](int x1, int y1, int x2, int y2, int change) {
        diff[x1][y1] += change;
        diff[x2+1][y1] -= change;
        diff[x1][y2+1] -= change;
        diff[x2+1][y2+1] += change;
    };

    for (int i=1; i <= m; i++) {
        for (int j=1; j<= n; j++) {
            update(i, j, i, j, matrix[i][j]);
        }
    }

    int x1, y1, x2, y2, change;
    while (t-->0) {
        cin>>x1>>y1>>x2>>y2>>change;
        update(x1, y1, x2, y2, change);
    }

    for (int i=1; i <= m; i++) {
        for (int j=1; j<= n; j++) {
            diff[i][j] += diff[i-1][j] + diff[i][j-1] - diff[i-1][j-1];
        }
    }

    for (int i=1; i <= m; i++) {
        for (int j=1; j<= n; j++) {
            cout<<diff[i][j]<<" ";
        }
        cout<<endl;
    }

    return 0;
}
